#import "OmBaseButton.h"
@interface OmBaseButton ()
@end
@implementation OmBaseButton
- (instancetype)initWithImageName:(NSString *)name
                       imageFrame:(CGRect)frame
                            title:(NSString *)title
                        titleFont:(UIFont *)font
                      titleOrigin:(CGPoint)origin
                       titleColor:(UIColor *)color {
    self = [super init];
    if (self) {
        self.coolImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(name)];
        [self addSubview:self.coolImageView];
        [self.coolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(frame.size.width));
            make.height.equalTo(@(frame.size.height));
            make.top.equalTo(self).offset(frame.origin.y);
            make.left.equalTo(self).offset(frame.origin.x);
        }];
        self.coolLabel = [[UILabel alloc] init].fp_text(title).fp_font(font).fp_textColor(color);
        [self addSubview:self.coolLabel];
        [self.coolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(origin.y);
            make.left.equalTo(self).offset(origin.x);
        }];
    }
    return self;
}
- (instancetype)initWithImageName:(NSString *)name
                        imageSize:(CGSize)size
                 imageTopDistance:(CGFloat)top
                            title:(NSString *)title
                        titleFont:(UIFont *)font
                       titleColor:(UIColor *)color
              titleBottomDistance:(CGFloat)bottom {
    self = [super init];
    if (self) {
        self.coolImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(name)];
        [self addSubview:self.coolImageView];
        [self.coolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(size.width));
            make.height.equalTo(@(size.height));
            make.top.equalTo(self).offset(top);
            make.centerX.equalTo(self);
        }];
        self.coolLabel = [[UILabel alloc] init].fp_text(title).fp_font(font).fp_textColor(color);
        [self addSubview:self.coolLabel];
        [self.coolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-bottom);
            make.centerX.equalTo(self);
        }];
    }
    return self;
}
- (instancetype)initWithImageName:(NSString *)name mode:(UIViewContentMode)mode {
    self = [super init];
    if (self) {
        self.coolImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(name)].fp_contentMode(mode);
        [self addSubview:self.coolImageView];
        [self.coolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.bottom.equalTo(self);
        }];
    }
    return self;
}
- (instancetype)initWithImageName:(NSString *)name
                        imageSize:(CGSize)size
               imageRightDistance:(CGFloat)right
                            title:(NSString *)title
                        titleFont:(UIFont *)font
                       titleColor:(UIColor *)color
                titleLeftDistance:(CGFloat)left {
    self = [super init];
    if (self) {
        self.coolImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(name)];
        [self addSubview:self.coolImageView];
        [self.coolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(size.width));
            make.height.equalTo(@(size.height));
            make.right.equalTo(self).offset(-right);
            make.centerY.equalTo(self);
        }];
        self.coolLabel = [[UILabel alloc] init].fp_text(title).fp_font(font).fp_textColor(color);
        [self addSubview:self.coolLabel];
        [self.coolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(left);
            make.centerY.equalTo(self);
        }];
    }
    return self;
}
- (instancetype)initWithImageName:(NSString *)name
                        imageSize:(CGSize)size
                imageLeftDistance:(CGFloat)left
                            title:(NSString *)title
                        titleFont:(UIFont *)font
                       titleColor:(UIColor *)color
               titleRightDistance:(CGFloat)right {
    self = [super init];
    if (self) {
        self.coolImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(name)];
        [self addSubview:self.coolImageView];
        [self.coolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(size.width));
            make.height.equalTo(@(size.height));
            make.left.equalTo(self).offset(left);
            make.centerY.equalTo(self);
        }];
        self.coolLabel = [[UILabel alloc] init].fp_text(title).fp_font(font).fp_textColor(color);
        [self addSubview:self.coolLabel];
        [self.coolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-right);
            make.centerY.equalTo(self);
        }];
    }
    return self;
}
- (instancetype)initAutoWidthHorizontalButtonWithImageName:(NSString *)name
                                                 imageSize:(CGSize)size
                                                     title:(NSString *)title
                                                 titleFont:(UIFont *)font
                                                titleColor:(UIColor *)color
                                                  distance:(CGFloat)distance
                                              isImageRight:(BOOL)isImageRight {
    self = [super init];
    if (self) {
        self.coolImageView = [[UIImageView alloc] initWithImage:IMAGE_NAMED(name)];
        [self addSubview:self.coolImageView];
        [self.coolImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(size.width));
            make.height.equalTo(@(size.height));
            make.centerY.equalTo(self);
            if (isImageRight) {
                make.right.equalTo(self);
            } else {
                make.left.equalTo(self);
            }
        }];
        self.coolLabel = [[UILabel alloc] init].fp_text(title).fp_font(font).fp_textColor(color);
        [self addSubview:self.coolLabel];
        [self.coolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            if (isImageRight) {
                make.left.equalTo(self);
                make.right.equalTo(self.coolImageView.mas_left).offset(RPX(-distance));
            } else {
                make.right.equalTo(self);
                make.left.equalTo(self.coolImageView.mas_right).offset(RPX(distance));
            }
        }];
    }
    return self;
}
@end
